/*
** team.c for  in /home/faye_m//zappy
** 
** Made by mouhamed faye
** Login   <faye_m@epitech.net>
** 
** Started on  Wed Jun 22 20:49:36 2011 mouhamed faye
** Last update Sun Jul 10 22:17:50 2011 vincent ricard
*/
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "team.h"
#include "types.h"

void	display_team(Class_team *all_team, int max, T_env *e)
{
  Class_team *tmp = all_team;
  char		*tna;
  int i = 0;
  if (max != 0)
    {
      printf ("Teams :\n");
      while (tmp->next != NULL)
	{
	  i++;
	  printf ("\tName(%s)   Max(%d)\n", tmp->team_name, max);
	  tmp = tmp->next;
	}
    }
  else if (max  == 0)
    {
      tna = malloc(sizeof(char *) * 10);
      if (tna  == NULL)
	return;
      bzero(tna, strlen(tna));
      while (tmp->next != NULL)
	{
	  strcat(tna, "tna ");
	  strcat(tna, tmp->team_name);
	  strcat(tna, "\n");
	  tmp = tmp->next;
	}
      if (write (e->i, tna, strlen(tna)))
	printf("%d: Sendind list team to %d\n", current_time(), e->i);
    }
}
